AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )

function GM:FragLimitThink()

	if ( GAMEMODE.IsEndOfGame ) then return end

	for k, ply in pairs( player.GetAll() ) do

		if ( !IsValid( ply ) ) then continue end
		if ( ply:Team() == TEAM_SPECTATOR ) then continue end
		if ( ply:Team() == TEAM_UNASSIGNED ) then continue end

		if ( ply:Frags() >= GAMEMODE.FragLimit ) then
			GAMEMODE:EndOfGame( true )
		end

	end

end
timer.Create( "FragLimitThink", 1, 0, function() GAMEMODE:FragLimitThink() end )

function GM:PlayerFootstep( ply, pos, foot, sound, volume, rf )
	ply:EmitSound("NPC_Hunter.Footstep")

	if (ply:Team() == TEAM_GHOSTS) then

		-- http://wiki.garrysmod.com/?title=Gamemode.PlayerFootstep
		-- http://wiki.garrysmod.com/?title=Entity.SetColor

		if ply:IsValid() then
			if ply:GetVelocity():Length() > 0 then
				-- is being rotated
				ply:SetColor(255, 0, 0, 255)
			else
				ply:SetColor(255, 255, 0, 255)
			end
		end
	end

	return true -- Don't allow default footsteps
 end



function SchoolShow( ply )
	ply:ConCommand( "SchoolMe" )
end
hook.Add("ShowSpare1", "School", SchoolShow)